<?php

if (isset($this->currentUrl)) {
	$onclickStart = $onclickPrevious = $onclickNext = $onclickEnd = '';
	$linkStart 		= $this->currentUrl . '/page/' . $this->first;
	
	$linkPrevious = '#';
	if(isset($this->previous)){
		$linkPrevious 	= $this->currentUrl . '/page/' . $this->previous;
	}
	$linkNext = '#';
	if(isset($this->next)){
		$linkNext 		= $this->currentUrl . '/page/' . $this->next;
	}
	
	$linkEnd = $this->currentUrl . '/page/' . $this->last;
	
	$strPage = '';
	foreach ($this->pagesInRange as $key) {
		if($this->current == $key) {
			$strPage .= '<span class="active"><b>' . $key . '</b></span>';
		} else {
			$linkPage = $this->currentUrl . '/page/' . $key;
			$strPage .= '<a class="num-page" href="' . $linkPage . '">' . $key .'</a>';
		}
	}
} else {
	$linkStart = $linkPrevious = $linkNext = $linkEnd = 'javascript:;';
	$onclickStart = 'onclick="gotoPage(' . $this->ajax . $this->first .');"';
	$onclickPrevious = 'onclick="gotoPage(' . $this->ajax . $this->previous .');"';
	$onclickNext = 'onclick="gotoPage(' . $this->ajax . $this->next .');"';
	$onclickEnd = 'onclick="gotoPage(' . $this->ajax . $this->last .');"';
	
	$strPage = '';
	foreach ($this->pagesInRange as $key) {
		if($this->current == $key) {
			$strPage .= '<span class="active"><b>' . $key . '</b></span>';
		} else {
			$linkPage = 'onclick="gotoPage(' . $this->ajax . $key .');"';
			$strPage .= '<a class="num-page" ' . $linkPage . ' href="javascript:;">' . $key .'</a>';
		}
	}
}
?>

<?php if ($this->last > 0) { ?>

<ul>
<?php
	if ($this->current > 1) {
		echo '<li class="previous"><span class="page-left"><a class="btn-page" ' . $onclickStart . ' href="' . $linkStart . '" title="Trang đầu"><i class="icon-backward"></i></a></span></li>';
		echo '<li class="previous"><span class="pre-span-page"><a class="btn-page" ' . $onclickPrevious . ' href="' . $linkPrevious . '" title="Trang trước">Trước</a></span></li>';
	} else {
		echo '<li class="disabled"><span class="page-left"><i class="icon-backward"></i></span></li>';
		echo '<li class="disabled"><span class="pre-span-page">Trước</span></li>';
	}
?>
	<li><?php echo $strPage;?></li>
<?php
	if ($this->current < $this->last) {
		echo '<li class="next"><span class="next-span-page"><a class="btn-page" ' . $onclickNext . ' href="' . $linkNext . '" title="Trang kế" >Sau</a></span></li>';
		echo '<li class="next"><span class="page-right"><a class="btn-page" ' . $onclickEnd . ' href="' . $linkEnd . '" title="Trang cuối" ><i class="icon-forward"></i></a></span></li>';
	} else {
		echo '<li class="disabled"><span class="next-span-page">Sau</span></li>';
		echo '<li class="disabled"><span class="page-right"><i class="icon-forward"></i></span></li>';
	}
?>
</ul>

<?php }?>